<div data-page="<{$pageName}>" class="page <{$pageName}>">
    <div class="page-content" style=" background-color:#e7e8eb; padding-top:40px">
        <div class="container photoBrowser" style="background-color:#FFFFFF; padding:0px;  border: 1px solid #d9dadc;">
            <div class="container-hd"> 申请校园合伙人 </div>
            <div style="padding:20px" class="wap-padding-0">
                <form class="form-horizontal pd10" data-type="ajaxSubmit" action="<{:U('User/apply_agent')}>" method="post" id="apply_apply_agent">
                    <div class="info-box">
                        <div class="info-hd">校园协议</div>
                        <div class="data-box">
                            <div>
                                <{:dict( 'apply_agent_num_text')}>
                            </div>
                            <div class="form-group" align="right"> <a target="_blank" data-type="link" href="http://kaoshituji.img-cn-shanghai.aliyuncs.com/Uploads/default/20160912/57d6af1f0de8f.jpg" class="btn-default btn  btn-sm">下载协议</a> <a style="position:relative" class="btn-primary btn  btn-sm"> 上传协议
						<input type="file" onchange="agreement_file(this)"  name="agreement" style="position:absolute; top:0px; width:100%; left:0px; height:30px;filter:alpha(opacity=0); -moz-opacity:0; opacity:0;" />
						</a>
                                <input type="hidden" name="agreement_file_name" value="<{$apply['agreement']['file_url']}>" />
                                <p id="agreement_file_text" <if condition="!$apply['agreement']">style="display:none"</if>
                                    >已选择协议文件：<span><a id="agreement_file_url" href="<php>echo ImgDomain</php>/<{$apply['agreement']['file_url']}>" target="_blank" ><{$apply['agreement']['file_name']}></a></span>
                                </p>
                            </div>
                        </div>
                    </div>
                    <{:displayFormGroupHtml( "AgentApply",$apply,$from_id)}>
                        <div class="info-box">
                            <div class="info-hd">操作/审核结果</div>
                            <div class="data-box">
                                <if condition="$apply['status']">
                                    <div class="form-group">
                                        <div class="col-sm-2 control-label"><strong>状态</strong></div>
                                        <div class="col-sm-8">
                                            <div style="color:red;margin-top:7px">
                                                <if condition="$apply['status'] eq 1"> 信息已经提交，等待审核 </if>
                                                <if condition="$apply['status'] eq 2 and $apply['expirationTime'] gt time()"> 审核通过,有效期至：
                                                    <{:date( "Y-m-d",$apply[ 'expirationTime'])}>
                                                </if>
                                                <if condition="$apply['status'] eq 3"> 审核不通过 </if>
                                                <if condition="$apply['status'] eq 4">您退出校园代理 </if>
                                            </div>
                                        </div>
                                    </div>
                                </if>
                                <if condition="$apply['remark']">
                                    <div class="form-group">
                                        <div class="col-sm-2 control-label"><strong>备注</strong></div>
                                        <div class="col-sm-8">
                                            <p style="margin-top:7px">
                                                <{$apply.remark}>
                                            </p>
                                        </div>
                                    </div>
                                </if>
                                <if condition="$apply['status'] neq 2 && $apply['status'] neq 1">
                                    <div class="form-group">
                                        <div class="col-sm-2"></div>
                                        <div class="col-sm-8">
                                            <button type="submit" class="btn-primary btn border-radius-none btn-lg">申请成为校园合伙人</button>
                                        </div>
                                    </div>
                                </if>
                                <if condition="$apply['status'] eq 2 and $apply['expirationTime'] gt time()">
                                    <div class="form-group">
                                        <div class="col-sm-2"></div>
                                        <div class="col-sm-8"> <a data-type="ajaxGet" confirm=1 title="确认退出校园代理吗？" id="quitAgent" href="<{:U('User/quitAgent')}>" class="btn-primary btn border-radius-none btn-lg">退出校园合伙人</a> </div>
                                    </div>
                                </if>
                            </div>
                        </div>
                </form>
            </div>
        </div>
    </div>
    <script>

    $(function() {
        $("#apply_apply_agent")._bootstrapValidator({
            excluded: ':disabled',
            fields: {
                agreement_file_name: {
                    validators: {
                        notEmpty: {
                            message: '请上传协议'
                        }
                    }
                },

            }
        });

        $("#quitAgent").on("ajaxGetSuccess", function(event, content) {
            var data = JSON.parse(content);
            if (data.error > 0) {
                dialog(data.msg);
            } else {
                dialog(data.msg, function() {
                    window.location.reload();
                }, 500)
            }
        })



        $("#apply_apply_agent").on("ajaxSubmitSuccess", function(event, content) {
            var data = JSON.parse(content);
            if (data.error > 0) {
                dialog(data.msg);
            } else {
                dialog(data.msg, function() {
                    window.location.reload();
                }, 500)
            }
        })

    })

    function agreement_file(_this) {
        var o = $(_this).val();
        var pos = o.lastIndexOf("\\");
        var name = o.substring(pos + 1);
        if (name != "") {
            $("#agreement_file_text").find("span").text(name);
            $("#agreement_file_text").show();
            $("[name='agreement_file_name']").val(name);
            $("#apply_apply_agent").bootstrapValidator('updateStatus', 'agreement_file_name', 'VALID');
        } else {
            $("#agreement_file_text").hide();
            $("[name='agreement_file_name']").val("");
        }
        $("#apply_apply_agent").data('bootstrapValidator').disableSubmitButtons(false);
    }
    </script>
</div>
